﻿import request from "@/utils/request";

// 查询文章列表
export function articleList(query) {
  return request({
    url: "/article/articleList",
    method: "get",
    headers: {
      isToken: false
    },
    params: query
  });
}

//查询最热文章
export function hotArticleList() {
  return request({
    url: "/article/hotArticleList",
    headers: {
      isToken: false
    },
    method: "get"
  });
}
//查询最新文章
export function newArticleList() {
  return request({
    url: "/article/newArticleList",
    headers: {
      isToken: false
    },
    method: "get"
  });
}

//获取文章详情
export function getArticle(articleId) {
  return request({
    url: "/article/" + articleId,
    headers: {
      isToken: false
    },
    method: "get"
  });
}

export function updateViewCount(articleId) {
  return request({
    url: "/article/updateViewCount/" + articleId,
    headers: {
      isToken: false
    },
    method: "put"
  });
}

export function getToal() {
  return request({
    url: "/article/getTotal",
    method: "get"
  });
}


// -------------------------------

// 查询分类列表

export function uploadImg(img) {
  const formData = new FormData()
  formData.append('img', img)
  return request({
    url: '/img/upload',
    headers: { 'Content-Type': 'multipart/form-data' },
    method: 'post',
    data: formData
  })
}
// 查询文章列表
export function addArticle(data) {
  return request({
    url: '/blog/article',
    method: 'post',
    data: data
  })
}
// 修改分类
export function updateArticle(data) {
  return request({
    url: '/content/article',
    method: 'put',
    data: data
  })
}
// 查询分类列表
export function listAllTag() {
  return request({
    url: '/content/tag/listAllTag',
    method: 'get'
  })
}